/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.zb.hms.face.init.controller;

import com.zb.hms.base.util.messageUtil.ResultMessage;
import com.zb.hms.base.util.propertiesUtil.LoadPropertiesUtil;
import com.zb.hms.data.hms.user.entity.User;
import com.zb.hms.data.hms.user.service.inter.UserServiceInter;
import com.zb.watermark.inter.WaterMarkInter;

import java.io.IOException;
import java.util.List;
import java.util.Properties;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;

import jdk.nashorn.internal.runtime.options.Options;

import org.apache.log4j.Logger;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

/**
 *
 * @Description
 * @author zb
 * @datetime 2017-7-30 14:43:14
 * @version V1.0
 * @serial JDK 1.8
 */
@Controller
@RequestMapping("/init")
public class RegisterController {
    @Resource
    private UserServiceInter userService;
    @Resource
    private ResultMessage resultMessage;
        /**
         * 邮箱检查
         * @param email
         * @return 
         */
        @RequestMapping("/Pubverify")
        @ResponseBody
        public Boolean verify(@RequestParam(name = "email") String email){                	
            return  userService.existsEamil(email);
        }  
       /**
        * 注册表单提交
        * @param user
        * @param result
        * @param verify
        * @param multipartFile
        * @param session
        * @return 
        */
        @RequestMapping("/Pubregister")
        @ResponseBody
        public ResultMessage register(@Valid User user,BindingResult result, @RequestParam(name="headImg",required = true)CommonsMultipartFile multipartFile){                  	
        	resultMessage.setType("result");
        	if(100==resultMessage.setValidataResult(result).getStatus()){     
        		 resultMessage.setMessage("恭喜，注册成功！");
        	}
        	 return resultMessage;
        }
        @Resource
        private LoadPropertiesUtil loadPropertiesUtil;
        @RequestMapping("/test")
        public void s(){
        	Logger.getInstance(this.getClass()).info("fghfdjhfdsgjfdg");
        	System.out.println(Logger.getInstance(this.getClass()).getLevel());
//        	System.out.println(loadPropertiesUtil.getValue("mail.from"));
        }
}
